package com.temi.iot.controller;


import com.temi.iot.common.constant.result.Page;
import com.temi.iot.common.constant.result.Result;
import com.temi.iot.entity.SysRole;
import com.temi.iot.service.ISysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author one
 * @since 2019-12-11
 */
@Api(description = "权限相关")
@RestController
@RequestMapping("/sys-role")
public class SysRoleController {

    @Autowired
    private ISysRoleService sysRoleService;

    @ApiOperation("增加角色")
    @PostMapping
    public Result insertRole(SysRole sysRole){
        return sysRoleService.insertRole(sysRole);
    }

    @ApiOperation("修改角色")
    @PutMapping
    public Result updateRole(SysRole sysRole){
        return sysRoleService.updateRole(sysRole);
    }

    @ApiOperation("增加角色")
    @DeleteMapping
    public Result deleteRole(Long id){
        return sysRoleService.deleteRole(id);
    }

    @ApiOperation("角色详情")
    @GetMapping
    public Result selectRoleDetail(Long id){
        return sysRoleService.selectRoleDetail(id);
    }

    @ApiOperation("角色列表")
    @GetMapping("/list")
    public Page selectRoleList(){
        return sysRoleService.selectRoleList();
    }

}
